
SRC    :=  $(shell find . -iname '*.c' -o -iname '*.cpp')

OBJ := $(patsubst %.c,%.o, $(patsubst %.cpp,%.o, $(SRC))) 




PROGRAM = demo_vpr_signalway_vfr
#CC := gcc
#CXX := g++
#AR := ar
#STRIP := strip
TARGET_PLATFORM =
SUFFIX=
CC=	gcc
CXX= g++
AR= ar
STRIP= strip

CFLAG =  -Wall -O2 -fPIC

CXXFLAG := $(CFLAG)


#LIBPATH += ./lib
#OUTPUT_PATH += ./bin
#LIBPATH=-L../hengSheng_plate
LIBPATH = 
OUTPUT_PATH=
DEFAULT_LIB_INSTALL_PATH =.:./xlw_lib

LDFLAG = -lpthread -lrt -ldl -Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)
LDFLAG += -lHvdevice
LDFLAG += -lvpr_signalway_vfr
LDFLAG += -lVideoSaver_ff
LDFLAG += -lH264_linux
LDFLAG += -ljpeg
# LDFLAG += -lturbojpeg
LDFLAG += -lavcodec -lavformat -lavutil -lswresample -lswscale
LDFLAG += -lx264
LDFLAG += -lSDL2



INC := -I.


#X86:LIBPATH
X86:OUTPUT_PATH += ./bin_x86
X86:$(PROGRAM)
		
		
_ARM:SUFFIX += _arm
_ARM:TARGET_PLATFORM += aarch64-linux-gnu-
_ARM:LIBPATH += -L/home/huma/tool/ffmpeg-4.2.4/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib
_ARM:LIBPATH += -L/home/huma/tool/libx264/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib
_ARM:LIBPATH += -L/home/huma/tool/libH264_linux/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu
_ARM:LIBPATH += -L/home/huma/tool/libSDL2-2.0.12/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib
_ARM:LIBPATH += -L/home/huma/tool/libHvdevice/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu
_ARM:LIBPATH += -L/home/huma/tool/jpeg-8d1/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib
# _ARM:LIBPATH += -L/home/huma/tool/libjpeg-turbo-2.1.3/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib
_ARM:LIBPATH += -L/home/huma/tool/libVideoSaver_ff/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu
_ARM:LIBPATH += -L/home/huma/tool/libvpr_signalway_vfr/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu
_ARM:OUTPUT_PATH += ./bin_arm
_ARM:$(PROGRAM)

X64:SUFFIX += _arm
X64:TARGET_PLATFORM +=
X64:LIBPATH += -L/home/huma/tool/libH264_linux_ffmpeg4.2.4/X86_64
#X64:LIBPATH += -L/home/huma/tool/jpeg-8d1/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib
X64:LIBPATH += -L/home/huma/tool/libVideoSaver_ff_ffmpeg4.2.4/x86_64
X64:LIBPATH += -L/home/huma/tool/libHvdevice/x86_64
X64:LIBPATH += -L/home/huma/tool/libvpr_signalway_vfr/X86_64
X64:LIBPATH += -L/home/huma/tool/libffmpeg4.2.4/x86_64
#X64:LIBPATH += -L/home/huma/tool/libx264/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib
X64:LIBPATH += -L/home/huma/tool/libSDL2/x86_64/lib
X64:OUTPUT_PATH += ./bin_x64
X64:$(PROGRAM)

#all:$(PROGRAM)

#debug version
debug:	CFLAG += -g3
debug:	OUTPUT_PATH += ./bin
debug:	$(PROGRAM)

#release version
release:	CFLAG += -g3
release:$(PROGRAM)


Q =
W := -w

.c.o:
	@echo "Compile $@"
	$(Q)$(TARGET_PLATFORM)$(CC) $(CFLAG) -o $@ -c $< $(INC) $(W)

.cpp.o:
	@echo "Compile $@"
	$(Q)$(TARGET_PLATFORM)$(CXX) $(CXXFLAG) -o $@ -c $< $(INC) $(W)
	
	
$(PROGRAM):$(OBJ)
	$(Q)$(TARGET_PLATFORM)$(CXX) -o $(PROGRAM) $(OBJ)  $(LIBPATH)  $(LDFLAG)
#	$(Q)rm *.o
#	$(Q)mkdir -p $(OUTPUT_PATH)
#	$(Q)cp $@ $(OUTPUT_PATH)/$@

clean:
	$(Q)rm -rf $(PROGRAM) $(OUTPUT_PATH)/$(PROGRAM) $(OBJ) 
